package tool;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.log4j.Logger;
import net.sf.json.JSONObject;

public class ReadUrl2 {
	private static Logger logger = Logger.getLogger(ReadUrl2.class);

	
	public static String loadJson(String url ,String argName){
		
		String json = loadJson(url);
		JSONObject jsonObject = JSONObject.fromObject(json);
		return jsonObject.getString(argName);

	}
	
	
	public static String loadJson (String url) {  
        StringBuilder json = new StringBuilder();  
        try {  
            URL urlObject = new URL(url);  
            URLConnection uc = urlObject.openConnection();  
            BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(),"UTF-8"));  
            String inputLine = null;  
            while ( (inputLine = in.readLine()) != null) {  
                json.append(inputLine);  
            }  
            in.close();  
        } catch (MalformedURLException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        return json.toString();  
    }  
	
	
	public static void main(String[] args) throws Exception {  
		
    }  

}
